"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Load template config.
 * @todo
 * - Adapt to any repository?
 * - Template dependencies not found.
 * - Check template is available.
 */
exports.default = async (ctx) => {
    // default template name
    ctx.config.name = ctx.template;
    try {
        const mod = require(ctx.src);
        if (Object.prototype.toString.call(mod) !== '[object Object]') {
            throw new TypeError('template needs to expose an object.');
        }
        Object.assign(ctx.config, mod);
    }
    catch (e) {
        if (e.code === 'MODULE_NOT_FOUND')
            return;
        e.message = `Invalid template: ${e.message}`;
        throw e;
    }
};
